# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=camlidl
pkgver=1.09
_pkgver=${pkgver/\./}
pkgrel=1
pkgdesc='A stub code generator and COM binding for Objective Caml (OCaml).'
arch=('x86_64' 'aarch64')
url='http://caml.inria.fr/pub/old_caml_site/camlidl/'
license=('custom:unknown')
depends=('ocaml')
source=("https://github.com/xavierleroy/$pkgname/archive/$pkgname$_pkgver.tar.gz"
        'arch-build-system-fix.patch'
        'META.camlidl')
sha512sums=('6cab1fa6bc2afba9b97874520eed2887c4fd341b59735854b120aa1ec8822710d9ebfadd1fecff56e629d4a1af7ee73befe6440c5462493f8408bdae8519a1fa'
            'f33b2f2ada43a1d178c5bb8a389f7bf936931a11159b06fa38f9eb22b5d816ed4eff82210146cff669c3a5c5950b329b9f3efc0f79d69b0a9924dfb25e9ccbe2'
            'c62d52405d02d1fd59cd7f91494183f8677f52d76a49509e56375ff5ba2645e0cc71adbc2540e06da9dd2fe324a6c2f1990345a1f15d087e1f0b7ef216ca3f43')

prepare() {
  cd "$pkgname-$pkgname$_pkgver"

  #patch -Np1 -i "$srcdir/arch-build-system-fix.patch"

  cp config/Makefile.unix config/Makefile
}

build() {
  cd "$pkgname-$pkgname$_pkgver"

  make all
}

package() {
  cd "$pkgname-$pkgname$_pkgver"

  _bindir="$pkgdir/usr/bin"
  _ocamldir="$pkgdir/$(ocamlc -where)"

  mkdir -p "$_bindir" "$_ocamldir"/{caml,stublibs,$pkgname}

  make BINDIR="$_bindir" OCAMLLIB="$_ocamldir" install

  install -Dm 644 "$srcdir/META.camlidl" "$_ocamldir/$pkgname/META"
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

